/*
 * 作者：姚俊
 * 功能：专著未审核的action
 * 日期：2015-06-08
 */
package admin.action.checkSearch;

import java.util.List;

import com.opensymphony.xwork2.ActionContext;

import admin.action.fruits.Constant;
import admin.service.fruits.TreatiseService;

import teacher.bean.Treatise;

public class SearchTreatiseUncheckAction {
	
	private List<Treatise> treatises;
	//当前页
	private int currentPage;
	//最后一页
	private int endPage;
	private int counts;
	private int flag;

	public List<Treatise> getTreatises() {
		return treatises;
	}

	public void setTreatises(List<Treatise> treatises) {
		this.treatises = treatises;
	}
	
	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getEndPage() {
		return endPage;
	}

	public void setEndPage(int endPage) {
		this.endPage = endPage;
	}

	public int getCounts() {
		return counts;
	}

	public void setCounts(int counts) {
		this.counts = counts;
	}

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

	public String execute()
	{
		 //当前页为零的时候，把当前页变成1
		if(this.getCurrentPage()==0)
			this.setCurrentPage(1);
		
		int add=0;
		//最后一页
		if(new TreatiseService().getCountTreatiseByState(4)%Constant.pageSize!=0)
		{
			add=1;
		}
		
		System.out.println("当前页为:"+this.getCurrentPage());
		this.setEndPage(new TreatiseService().getCountTreatiseByState(4)/Constant.pageSize+add);
		this.setCounts(new TreatiseService().getCountTreatiseByState(4));
		ActionContext.getContext().put("flag", 3);
		this.setFlag(3);

		this.setTreatises(new TreatiseService().getSegregateTreatiseByState(4,
				(this.getCurrentPage()-1)*Constant.pageSize+1,Constant.pageSize));

        return "succ";
	}

}
